package com.gigalaxy.game.protocol {
	import com.netease.protobuf.*;
	import com.netease.protobuf.fieldDescriptors.*;
	import flash.utils.Endian;
	import flash.utils.IDataInput;
	import flash.utils.IDataOutput;
	import flash.utils.IExternalizable;
	import flash.errors.IOError;
	import com.gigalaxy.game.protocol.CardsData;
	// @@protoc_insertion_point(imports)

	// @@protoc_insertion_point(class_metadata)
	public dynamic final class GameUserData extends com.netease.protobuf.Message {
		public static const PLAYERNAME:FieldDescriptor$TYPE_STRING = new FieldDescriptor$TYPE_STRING("com.gigalaxy.game.protocol.GameUserData.playerName", "playerName", (1 << 3) | com.netease.protobuf.WireType.LENGTH_DELIMITED);

		private var playerName$field:String;

		public function clearPlayerName():void {
			playerName$field = null;
		}

		public function get hasPlayerName():Boolean {
			return playerName$field != null;
		}

		public function set playerName(value:String):void {
			playerName$field = value;
		}

		public function get playerName():String {
			return playerName$field;
		}

		public static const FULLNAME:FieldDescriptor$TYPE_STRING = new FieldDescriptor$TYPE_STRING("com.gigalaxy.game.protocol.GameUserData.fullName", "fullName", (2 << 3) | com.netease.protobuf.WireType.LENGTH_DELIMITED);

		private var fullName$field:String;

		public function clearFullName():void {
			fullName$field = null;
		}

		public function get hasFullName():Boolean {
			return fullName$field != null;
		}

		public function set fullName(value:String):void {
			fullName$field = value;
		}

		public function get fullName():String {
			return fullName$field;
		}

		public static const POSITION:FieldDescriptor$TYPE_INT32 = new FieldDescriptor$TYPE_INT32("com.gigalaxy.game.protocol.GameUserData.position", "position", (3 << 3) | com.netease.protobuf.WireType.VARINT);

		private var position$field:int;

		private var hasField$0:uint = 0;

		public function clearPosition():void {
			hasField$0 &= 0xfffffffe;
			position$field = new int();
		}

		public function get hasPosition():Boolean {
			return (hasField$0 & 0x1) != 0;
		}

		public function set position(value:int):void {
			hasField$0 |= 0x1;
			position$field = value;
		}

		public function get position():int {
			return position$field;
		}

		public static const OWNER:FieldDescriptor$TYPE_BOOL = new FieldDescriptor$TYPE_BOOL("com.gigalaxy.game.protocol.GameUserData.owner", "owner", (4 << 3) | com.netease.protobuf.WireType.VARINT);

		private var owner$field:Boolean;

		public function clearOwner():void {
			hasField$0 &= 0xfffffffd;
			owner$field = new Boolean();
		}

		public function get hasOwner():Boolean {
			return (hasField$0 & 0x2) != 0;
		}

		public function set owner(value:Boolean):void {
			hasField$0 |= 0x2;
			owner$field = value;
		}

		public function get owner():Boolean {
			return owner$field;
		}

		public static const MONEY:FieldDescriptor$TYPE_INT32 = new FieldDescriptor$TYPE_INT32("com.gigalaxy.game.protocol.GameUserData.money", "money", (5 << 3) | com.netease.protobuf.WireType.VARINT);

		private var money$field:int;

		public function clearMoney():void {
			hasField$0 &= 0xfffffffb;
			money$field = new int();
		}

		public function get hasMoney():Boolean {
			return (hasField$0 & 0x4) != 0;
		}

		public function set money(value:int):void {
			hasField$0 |= 0x4;
			money$field = value;
		}

		public function get money():int {
			return money$field;
		}

		public static const RANK:FieldDescriptor$TYPE_INT32 = new FieldDescriptor$TYPE_INT32("com.gigalaxy.game.protocol.GameUserData.rank", "rank", (6 << 3) | com.netease.protobuf.WireType.VARINT);

		private var rank$field:int;

		public function clearRank():void {
			hasField$0 &= 0xfffffff7;
			rank$field = new int();
		}

		public function get hasRank():Boolean {
			return (hasField$0 & 0x8) != 0;
		}

		public function set rank(value:int):void {
			hasField$0 |= 0x8;
			rank$field = value;
		}

		public function get rank():int {
			return rank$field;
		}

		public static const NUMOFCARDS:FieldDescriptor$TYPE_INT32 = new FieldDescriptor$TYPE_INT32("com.gigalaxy.game.protocol.GameUserData.numOfCards", "numOfCards", (7 << 3) | com.netease.protobuf.WireType.VARINT);

		private var numOfCards$field:int;

		public function clearNumOfCards():void {
			hasField$0 &= 0xffffffef;
			numOfCards$field = new int();
		}

		public function get hasNumOfCards():Boolean {
			return (hasField$0 & 0x10) != 0;
		}

		public function set numOfCards(value:int):void {
			hasField$0 |= 0x10;
			numOfCards$field = value;
		}

		public function get numOfCards():int {
			return numOfCards$field;
		}

		public static const CARDS:RepeatedFieldDescriptor$TYPE_MESSAGE = new RepeatedFieldDescriptor$TYPE_MESSAGE("com.gigalaxy.game.protocol.GameUserData.cards", "cards", (8 << 3) | com.netease.protobuf.WireType.LENGTH_DELIMITED, com.gigalaxy.game.protocol.CardsData);

		[ArrayElementType("com.gigalaxy.game.protocol.CardsData")]
		public var cards:Array = [];

		/**
		 *  @private
		 */
		override public final function writeToBuffer(output:com.netease.protobuf.WritingBuffer):void {
			if (hasPlayerName) {
				com.netease.protobuf.WriteUtils.writeTag(output, com.netease.protobuf.WireType.LENGTH_DELIMITED, 1);
				com.netease.protobuf.WriteUtils.write$TYPE_STRING(output, playerName$field);
			}
			if (hasFullName) {
				com.netease.protobuf.WriteUtils.writeTag(output, com.netease.protobuf.WireType.LENGTH_DELIMITED, 2);
				com.netease.protobuf.WriteUtils.write$TYPE_STRING(output, fullName$field);
			}
			if (hasPosition) {
				com.netease.protobuf.WriteUtils.writeTag(output, com.netease.protobuf.WireType.VARINT, 3);
				com.netease.protobuf.WriteUtils.write$TYPE_INT32(output, position$field);
			}
			if (hasOwner) {
				com.netease.protobuf.WriteUtils.writeTag(output, com.netease.protobuf.WireType.VARINT, 4);
				com.netease.protobuf.WriteUtils.write$TYPE_BOOL(output, owner$field);
			}
			if (hasMoney) {
				com.netease.protobuf.WriteUtils.writeTag(output, com.netease.protobuf.WireType.VARINT, 5);
				com.netease.protobuf.WriteUtils.write$TYPE_INT32(output, money$field);
			}
			if (hasRank) {
				com.netease.protobuf.WriteUtils.writeTag(output, com.netease.protobuf.WireType.VARINT, 6);
				com.netease.protobuf.WriteUtils.write$TYPE_INT32(output, rank$field);
			}
			if (hasNumOfCards) {
				com.netease.protobuf.WriteUtils.writeTag(output, com.netease.protobuf.WireType.VARINT, 7);
				com.netease.protobuf.WriteUtils.write$TYPE_INT32(output, numOfCards$field);
			}
			for (var cards$index:uint = 0; cards$index < this.cards.length; ++cards$index) {
				com.netease.protobuf.WriteUtils.writeTag(output, com.netease.protobuf.WireType.LENGTH_DELIMITED, 8);
				com.netease.protobuf.WriteUtils.write$TYPE_MESSAGE(output, this.cards[cards$index]);
			}
			for (var fieldKey:* in this) {
				super.writeUnknown(output, fieldKey);
			}
		}

		/**
		 *  @private
		 */
		override public final function readFromSlice(input:flash.utils.IDataInput, bytesAfterSlice:uint):void {
			var playerName$count:uint = 0;
			var fullName$count:uint = 0;
			var position$count:uint = 0;
			var owner$count:uint = 0;
			var money$count:uint = 0;
			var rank$count:uint = 0;
			var numOfCards$count:uint = 0;
			while (input.bytesAvailable > bytesAfterSlice) {
				var tag:uint = com.netease.protobuf.ReadUtils.read$TYPE_UINT32(input);
				switch (tag >> 3) {
				case 1:
					if (playerName$count != 0) {
						throw new flash.errors.IOError('Bad data format: GameUserData.playerName cannot be set twice.');
					}
					++playerName$count;
					this.playerName = com.netease.protobuf.ReadUtils.read$TYPE_STRING(input);
					break;
				case 2:
					if (fullName$count != 0) {
						throw new flash.errors.IOError('Bad data format: GameUserData.fullName cannot be set twice.');
					}
					++fullName$count;
					this.fullName = com.netease.protobuf.ReadUtils.read$TYPE_STRING(input);
					break;
				case 3:
					if (position$count != 0) {
						throw new flash.errors.IOError('Bad data format: GameUserData.position cannot be set twice.');
					}
					++position$count;
					this.position = com.netease.protobuf.ReadUtils.read$TYPE_INT32(input);
					break;
				case 4:
					if (owner$count != 0) {
						throw new flash.errors.IOError('Bad data format: GameUserData.owner cannot be set twice.');
					}
					++owner$count;
					this.owner = com.netease.protobuf.ReadUtils.read$TYPE_BOOL(input);
					break;
				case 5:
					if (money$count != 0) {
						throw new flash.errors.IOError('Bad data format: GameUserData.money cannot be set twice.');
					}
					++money$count;
					this.money = com.netease.protobuf.ReadUtils.read$TYPE_INT32(input);
					break;
				case 6:
					if (rank$count != 0) {
						throw new flash.errors.IOError('Bad data format: GameUserData.rank cannot be set twice.');
					}
					++rank$count;
					this.rank = com.netease.protobuf.ReadUtils.read$TYPE_INT32(input);
					break;
				case 7:
					if (numOfCards$count != 0) {
						throw new flash.errors.IOError('Bad data format: GameUserData.numOfCards cannot be set twice.');
					}
					++numOfCards$count;
					this.numOfCards = com.netease.protobuf.ReadUtils.read$TYPE_INT32(input);
					break;
				case 8:
					this.cards.push(com.netease.protobuf.ReadUtils.read$TYPE_MESSAGE(input, new com.gigalaxy.game.protocol.CardsData()));
					break;
				default:
					super.readUnknown(input, tag);
					break;
				}
			}
		}

	}
}
